﻿using System.Diagnostics.CodeAnalysis;
using System.Linq;
using CultivationSkills.Skills;
using CultivationSkills.Utils;
using ThunderRoad;
using UnityEngine;

namespace CultivationSkills
{
    [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
    [SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Global")]
    [SuppressMessage("ReSharper", "ConvertToConstant.Global")]
    public class SkillController
    {
        
        [ModOption(name = "Test1", order = 3,
            valueSourceName = "BoolDefaultValues", category = "Test", defaultValueIndex = 0)]
        public static void Test1(bool shoot)
        {
            if (!Application.isPlaying || !Player.local || !shoot)
            {
                return;
            }

            if (GameUtils.FindForwardHitNpc(Player.local.head.transform, out var hit))
            {
                Debug.Log("head找到：" + hit.point);
            }
            else
            {
                Debug.Log("head没找到");
            }

            if (GameUtils.FindForwardHitNpc(Player.local.handRight.transform, out hit))
            {
                Debug.Log("handRight找到：" + hit.point);
            }
            else
            {
                Debug.Log("handRight没找到");
            }
        }


        [ModOption(name = "Test2", order = 4, interactionType = ModOption.InteractionType.ButtonList,
            valueSourceName = "BoolDefaultValues", category = "Test", defaultValueIndex = 0)]
        public static void Test2(bool spawn)
        {
            if (!Application.isPlaying || !Player.local || !spawn)
            {
                return;
            }
        }

        [ModOption(name = "Fly", order = 5, interactionType = ModOption.InteractionType.ButtonList,
            valueSourceName = "BoolDefaultValues", category = "Test", defaultValueIndex = 0)]
        public static void SetFly(bool fly)
        {
            if (!Application.isPlaying || !Player.local)
            {
                return;
            }

            SkillFlyBySword.ChangeFlyStatus(fly);
        }

        [ModOption(name = "Clear", order = 5, interactionType = ModOption.InteractionType.ButtonList,
            valueSourceName = "BoolDefaultValues", category = "Test", defaultValueIndex = 0)]
        public static void Clear(bool flag)
        {
            if (!Application.isPlaying || !Player.local || !flag)
            {
                return;
            }

            foreach (var item in Item.all.Where(item => item.itemId == SwordShoot.DefaultItemId))
            {
                item.Despawn();
            }
        }
    }
}